package event;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class ActionEventEx3 {

	JButton s = new JButton("남쪽");
	JButton n = new JButton("북쪽");
	JButton e = new JButton("동쪽");
	JButton w = new JButton("서쪽");
	JButton c = new JButton("중앙");

	public static void main(String[] args) {
		new ActionEventEx3();

	}

	public ActionEventEx3() {
		JFrame f = new JFrame("이벤트 테스트3");
		f.setBounds(100, 100, 300, 200);
		f.setVisible(true);

		f.add(s, BorderLayout.SOUTH);
		f.add(n, BorderLayout.NORTH);
		f.add(e, BorderLayout.EAST);
		f.add(w, BorderLayout.WEST);
		f.add(c, BorderLayout.CENTER);

		s.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent ev) {
				System.out.println("남쪽 버튼");
			}

		});

		n.addActionListener(new ActionListener() { // n.addActionListener{ new
													// ActionListener(){ 이것이
													// 원형!!
			@Override
			public void actionPerformed(ActionEvent ev) {
				System.out.println("북쪽 버튼");
			}

		});

		e.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent ev) {
				System.out.println("동쪽버튼");

			}
		});

		w.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent ev) {
				System.out.println("서쪽 버튼");
			}

		});

		c.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent ev) {
				System.out.println("중앙 버튼");
			}

		});

	}

}
